// apps/app1/src/router/index.ts
import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import Home from "@/views/Dashboard/index.vue";

// 路由规则
const routes: RouteRecordRaw[] = [
  {
    path: "/",
    redirect: "/home", // 默认跳转到 home 页面
  },
  {
    path: "/home",
    name: "Home",
    component: Home,
    meta: { title: "首页" },
  },
];

// 创建 router 实例
const router = createRouter({
  history: createWebHistory(), // 使用 history 模式
  routes,
});

// 路由守卫（可选）
router.beforeEach((to, from, next) => {
  // 设置页面标题
  if (to.meta.title) {
    document.title = `${to.meta.title} - 微应用 App1`;
  }
  next();
});

export default router;
